package com.lvkerry.orderfood.controller

import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import com.lvkerry.orderfood.service.ResourceService


@Controller
@RequestMapping("/image")
class ImageResController(private val resourceService: ResourceService) {


    @RequestMapping(value = ["/{filename:.+}"], method = [RequestMethod.POST, RequestMethod.GET])
    fun getImage(@PathVariable("filename") filename: String): ResponseEntity<Any> {
        return ResponseEntity.ok(resourceService.getResource(filename))
    }

}